<template>
	<div class="main">

		<div class="adOuterWrap">
			<div class="back">
				<headerBack></headerBack>
				<h2>选择综合测试结果<b class="newTestTitle" v-show="flag==false" @click="commonJs.gopush('../evaluation/evaluationEntry')">新的测试</b></h2>

			</div>
			<div class="adWrap">
				<scroller style="top: 1.6rem;">
					<div>
						<div class="adBoxs">
							<div class="listBox">
								<span v-show="flag" class="txtBox" @click="commonJs.gopush('../evaluation/evaluationEntry')">
									<i>您有未完成能的综合的测试</i>
									<b>点击继续</b>
								</span>
								<report-list v-on:fromChild='abc' :zhData='zhDatas'></report-list>
							</div>

						</div>
						<div style="width: 100%;height: 2.8rem;"></div>
					</div>

				</scroller>
				<!-- </div> -->
			</div>
			<div class="botFixed">
				<!-- <span @click="clicks()">添加到意向专业</span> -->
				<sumbitBtn message="添加到意向专业" @btnClick ="clicks"></sumbitBtn>
			</div>
		</div>
		<!-- </scroller> -->
	</div>
</template> 
<script>
	import ls from 'store2';
	import {
		format
	} from '~/plugins/filter';
	import headerBack from '~/components/headerBack'
	import reportList from '~/components/reportList1'
	import sumbitBtn from "./components/sumbitBtn";
	import { getEvaluation, getReportList } from "~/api/evaluation";
	export default {
		// head: {
		// 	title: '生涯测评'
		// },
		components: {
			headerBack,
			reportList,
			sumbitBtn
		},
		data() {
			return {
				zhDatas: [],
				flag: false,
				types: ''
			}
		},
		created() {
		},
		mounted: function() {
			this.$visit(this.$route.path)
			this.showZongheList()		
		},


		methods: {
			abc(data) {
				this.tabix = data
			},
			clicks() {
				let data = this.zhDatas;
				if (data.length == 0) {

					return false;
				}
				let obj = data[this.tabix].majors;
				this.commonJs.gosto('addIntention', JSON.stringify(obj))
			},
			showResultList() {
				// let userid = 1745680;263997
				let obj = {
					userId: ls.get('yxkData').userId,
					userType: ls.get('userType')
				}
				getEvaluation(obj).then(res => {
					if (res.code === '0') {

					}
				}).catch((error) => {
					this.$vux.toast.text('服务器繁忙，请稍后再试');
				})

			},
			showZongheList() {
				getReportList(ls.get('userType')).then(res => {
					if (res.code === '0') {
						if (res.data.length == 0) {

						} else {
							let zhData = res.data;
							// filter回调函数
							if (zhData[0].generate === 0) {
								this.flag = true;
							}
							var dofilter = function(element, index, array) {
								if (element.generate < 1) { // 年龄过滤
									return false;
								}
								return true;
							}

							/* test */
							this.zhDatas = zhData.filter(dofilter);
				
						}


					}
				}).catch((error) => {
					this.$vux.toast.text('服务器繁忙，请稍后再试');
				})
			},
			goto(routerName, queryData) {
				this.$router.replace({
					path: routerName,
					query: {
						type: queryData
					}
				})
			}

		},
		beforeDestroy() {

		}

	}
</script>

<style scoped lang="less">
	.adOuterWrap {
		width: 7.5rem;
		height: 100vh;
		background: #fff;
		flex-direction: column;
		overflow: hidden;

		.adWrap {

			padding: 0 0.3rem;
			width: 7.5rem;
			box-sizing: border-box;

			.adBoxs {
				width: 100%;
				height: auto;

				.listBox {
					height: auto;
					padding: 0.3rem 0.3rem;
					box-sizing: border-box;

					.txtBox {
						display: block;
						width: 100%;
						height: 0.8rem;
						background: rgba(255, 241, 184, 1);
						border-radius: 0.1rem;
						opacity: 0.6;
						text-align: center;
						line-height: 0.8rem;
						
						i,
						b {
			
							font-size: 0.28rem;
							font-weight: bold;
							
						}
						i{
							
							font-weight: 600;
							color:#222222;
						}
						b {
							margin-left: 0.1rem;
							color: @mainColor;
						}
					}

				}


			}
		}


	}

	.back {
		width: 100%;
		height: auto;

		h2 {
			padding: 0 0.3rem;
			box-sizing: border-box;
			display: block;
			height: 0.8rem;
			font-size: 0.44rem;

			font-weight: bold;
			color: rgba(34, 34, 34, 1);
			line-height: 0.8rem;

			.newTestTitle {
				float: right;
				font-size: 0.26rem;
				color: @mainColor;
			}
		}
	}

	.botFixed {
		position: fixed;
		height: 1.2rem;
		background: rgba(255, 255, 255, 1);
		box-shadow: 0px -4px 10px 0px rgba(204, 204, 204, 0.2);
		left: 0;
		bottom: 0;
		width: 7.5rem;
		overflow: hidden;
		padding: 0.2rem 0.6rem 0 0.6rem;
		box-sizing: border-box;
	}
</style>
